<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 判断一个字符串中出现次数最多的字符，统计这个次数
    var str = "safvdbakjsdhavjkdsnadbvkjsdakvdffdbjkasdvkadjvbadjvkb";
    var json = {}
    for(var i=0;i<str.length;i++){
        if(!json[str.charAt(i)]){
            json[str.charAt(i)] = 1;
        }else{
            json[str.charAt(i)]++;
        }
    }
    console.log(json);
    var iMax = 0;
    var iIndex = '';
    for(var j in json){
        if(json[j]>iMax){
            iMax = json[j];
            iIndex = j;
        }
    }
    console.log("出现次数最多的是"+iIndex+",出现了"+iMax+"次")
</script>
</html>